<?php

namespace App\Admin\Controllers;

use App\facebook;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class FacebookController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'App\facebook';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new facebook());

        $grid->filter(function($filter){

            // 去掉默认的id过滤器
            $filter->disableIdFilter();

            // 在这里添加字段过滤器
            $filter->like('Email', '登录邮箱');

        });

        $grid->column('Email', __('登录邮箱'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('Password', __('登录密码'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('Phone', __('注册手机'));
        $grid->column('RegistrationName', __('注册姓名'));
        $grid->column('Status', __('帐号状态'));
        $grid->column('SecondEmail', __('辅助邮箱'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('Remarks', __('备注'));


        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(facebook::findOrFail($id));


        $show->field('Email', __('登录邮箱'));
        $show->field('Password', __('登录密码'));
        $show->field('Phone', __('注册手机'));
        $show->field('RegistrationName', __('注册姓名'));
        $show->field('Status', __('帐号状态'));
        $show->field('SecondEmail', __('辅助邮箱'));
        $show->field('Remarks', __('备注'));


        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new facebook());


        $form->email('Email', __('登录邮箱'));
        $form->password('Password', __('登录密码'));
        $form->mobile('Phone', __('注册手机'));
        $form->text('RegistrationName', __('注册姓名'));
        $form->text('Status', __('帐号状态'));
        $form->email('SecondEmail', __('辅助邮箱'));
        $form->text('Remarks', __('备注'));


        return $form;
    }
}
